const db=require('../sql/sql')

exports.studentsendget=(req:object,res:any)=>{
    db.query(`select * from classtudent`,(err:any,data:object):void=>{
        if(err) throw err
        res.send(data)
    })
}

exports.studentaddget = (req:any,res:any)=>{
    // console.log(req.query);
    let {name , age , sex , address , date}=req.query
    let sql=`insert into classtudent value (null,?,?,?,?,?)`
    let datalist=[name , age , sex , address , date]
    db.query(sql,datalist,(err)=>{
        if (err) console.log(err);
        res.send({
            code:200,
            msg:'添加成功'
        })
        
    })
}

exports.studentdeleteget=(req:any,res:any)=>{
    // console.log(req.query.multipleSelection);
    let data=req.query.multipleSelection
    let st=data.join(',')
    let sql=`delete from classtudent where id in(${st})`
    db.query(sql,(err,data)=>{
        if(err)console.log(err);
        res.send({
            code:200,
            msg:'删除成功'
        })
    })
}